package com.gcb.common.core.domain;

import com.gcb.common.constant.HttpStatus;
import com.github.pagehelper.PageInfo;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 分页响应信息主体
 */
@Data
public class PageResult implements Serializable {
    private static final long serialVersionUID = 1L;

    private int code;

    private String msg;

    private List<?> data;

    private long total;

    public static PageResult ok(List<?> data) {
        return new PageResult(HttpStatus.SUCCESS, "操作成功", data, new PageInfo(data).getTotal());
    }


    public PageResult(int code, String msg, List<?> data, long total) {
        this.code = code;
        this.msg = msg;
        this.data = data;
        this.total = total;
    }
}
